package com.shitou.shitouproduct.controller;

import java.util.Arrays;
import java.util.Map;

import com.shitou.shitouproduct.entity.SpuImagesEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.shitou.shitouproduct.service.SpuImagesService;
import com.shitou.shitoucommons.utils.PageUtils;
import com.shitou.shitoucommons.utils.RespBean;



/**
 * spu图片
 *
 * @author 石头人
 * @email 3076767823@qq.com
 * @date 2023-03-04 18:03:45
 */
@RestController
@RequestMapping("shitouproduct/spuimages")
public class SpuImagesController {
    @Autowired
    private SpuImagesService spuImagesService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public RespBean list(@RequestParam Map<String, Object> params){
        PageUtils page = spuImagesService.queryPage(params);

        return RespBean.success().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{spuImgId}")
    public RespBean info(@PathVariable("spuImgId") Long spuImgId){
        SpuImagesEntity spuImages = spuImagesService.getById(spuImgId);

        return RespBean.success().put("spuImages", spuImages);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public RespBean save(@RequestBody SpuImagesEntity spuImages){
        spuImagesService.save(spuImages);

        return RespBean.success();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public RespBean update(@RequestBody SpuImagesEntity spuImages){
        spuImagesService.updateById(spuImages);

        return RespBean.success();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public RespBean delete(@RequestBody Long[] spuImgIds){
        spuImagesService.removeByIds(Arrays.asList(spuImgIds));

        return RespBean.success();
    }



}
